const log = console.log;

function fakeAsync(){
  const start = Date.now(),
        delay = Math.random()*1000;

  return new Promise((resolve,reject)=>{
    setTimeout(function(){
      const end = Date.now();
      log('fakeAsync use %dms',end-start);
      report(end-start);
      resolve(end-start);
    },delay);
  });
}

function report(cost){
  log(`This task done. use ${cost}ms.\n`);
}

module.exports = fakeAsync;
